package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceCancelorderreason;
import com.ruoyi.service.service.IServiceCancelorderreasonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单取消原因Controller
 * 
 * @author ZDL
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/service/cancelorderreason")
public class ServiceCancelorderreasonController extends BaseController
{
    @Autowired
    private IServiceCancelorderreasonService serviceCancelorderreasonService;

    /**
     * 查询订单取消原因列表
     */
    @PreAuthorize("@ss.hasPermi('service:cancelorderreason:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceCancelorderreason serviceCancelorderreason)
    {
        startPage();
        List<ServiceCancelorderreason> list = serviceCancelorderreasonService.selectServiceCancelorderreasonList(serviceCancelorderreason);
        return getDataTable(list);
    }

    /**
     * 导出订单取消原因列表
     */
    @PreAuthorize("@ss.hasPermi('service:cancelorderreason:export')")
    @Log(title = "订单取消原因", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceCancelorderreason serviceCancelorderreason)
    {
        List<ServiceCancelorderreason> list = serviceCancelorderreasonService.selectServiceCancelorderreasonList(serviceCancelorderreason);
        ExcelUtil<ServiceCancelorderreason> util = new ExcelUtil<ServiceCancelorderreason>(ServiceCancelorderreason.class);
        util.exportExcel(response, list, "订单取消原因数据");
    }

    /**
     * 获取订单取消原因详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:cancelorderreason:query')")
    @GetMapping(value = "/{cancelorderreasonId}")
    public AjaxResult getInfo(@PathVariable("cancelorderreasonId") Long cancelorderreasonId)
    {
        return success(serviceCancelorderreasonService.selectServiceCancelorderreasonByCancelorderreasonId(cancelorderreasonId));
    }

    /**
     * 新增订单取消原因
     */
    @PreAuthorize("@ss.hasPermi('service:cancelorderreason:add')")
    @Log(title = "订单取消原因", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceCancelorderreason serviceCancelorderreason)
    {
        return toAjax(serviceCancelorderreasonService.insertServiceCancelorderreason(serviceCancelorderreason));
    }

    /**
     * 修改订单取消原因
     */
    @PreAuthorize("@ss.hasPermi('service:cancelorderreason:edit')")
    @Log(title = "订单取消原因", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceCancelorderreason serviceCancelorderreason)
    {
        return toAjax(serviceCancelorderreasonService.updateServiceCancelorderreason(serviceCancelorderreason));
    }

    /**
     * 删除订单取消原因
     */
    @PreAuthorize("@ss.hasPermi('service:cancelorderreason:remove')")
    @Log(title = "订单取消原因", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cancelorderreasonIds}")
    public AjaxResult remove(@PathVariable Long[] cancelorderreasonIds)
    {
        return toAjax(serviceCancelorderreasonService.deleteServiceCancelorderreasonByCancelorderreasonIds(cancelorderreasonIds));
    }
}
